﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace FootBallMatchProject.Piography.Client
{
    public partial class ClubInfoForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataClassLayer.Club club = new DataClassLayer.Club();
            if (Request.QueryString["ID"] != null &&
                Request.QueryString["ID"].ToString() != "")
            {
                club.ID = int.Parse(Request.QueryString["ID"].ToString());
            }
            else
            {
                club.ID = 1;
            }
            DataClassLayer.ClubCollection clubs = new DataClassLayer.ClubCollection();
            DataTable table = clubs.FillList(club);
            if (table.Rows.Count == 1)
            {
                ClubView.DataSource = table;
                ClubView.DataBind();
            }
            DataClassLayer.Statistic statistic = new DataClassLayer.Statistic();
            DataClassLayer.StatisticCollection statistics = new DataClassLayer.StatisticCollection();
            if (Request.QueryString["ID"] != null &&
                Request.QueryString["ID"].ToString() != "")
            {
                statistic.ClubID = int.Parse(Request.QueryString["ID"].ToString());
            }
            else
            {
                statistic.ClubID = 1;
            }
            statistic.Year = DateTime.Now.Year;
            DataTable statistictable = statistics.FillList(statistic);
            if (statistictable.Rows.Count > 0)
            {
                ((DataList)ClubView.FindControl("StatisticsList")).DataSource = statistictable;
                ((DataList)ClubView.FindControl("StatisticsList")).DataBind();
            }
            DataTable playertable = clubs.FillListPlayers(club);
            if (playertable.Rows.Count > 0)
            {
                ((DataList)ClubView.FindControl("PlayerList")).DataSource = playertable;
                ((DataList)ClubView.FindControl("PlayerList")).DataBind();
            }
        }
    }
}